﻿using Inovout;
using Inovout.Data.Domain;
using KuaJing.Organization.Domain;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KuaJing.Orders.Domain
{
    partial class Customer : DataObject
    {
        public Customer()
        {
            Orders = new HashSet<Order>();
        }
        [DataProperty("名称", DataType.Text, null, true, null, null)]
        public virtual string Name { get; set; }
        [DataProperty("简称", DataType.Text, null, true, null, null)]
        public virtual string ShortName { get; set; }
        /// <summary>
        /// 客服人员
        /// </summary>
         public virtual Employee Butler { get; set; }
        /// <summary>
        /// 销售人员
        /// </summary>
        public virtual Employee Sales { get; set; }
        [DataProperty("签约日期", DataType.Date, "{0:yyyy-M-d}", false, null, null)]
        public virtual DateTime? SigningDate { get; set; }
        [UIHint("Enum"), DataProperty("业务主体", DataType.Text, null, true, null, null)]
        public virtual ServiceProvider Provider { get; set; }
        [UIHint("Enum"), DataProperty("来源", DataType.Text, null, true, null, null)]
        public virtual CustomerSource Source { get; set; }
        [DataProperty("省份", DataType.Text, null, true, null, null)]
        public virtual string Province { get; set; }
        [DataProperty("城市", DataType.Text, null, true, null, null)]
        public virtual string City { get; set; }
        public virtual ISet<Order> Orders { get; set; }
        private Order firstOrder;
        private DateTime? firstOrderDate;
        public virtual Order FirstOrder
        {
            get { return firstOrder; }
            set
            {
                firstOrder = value;
                if (firstOrder != null)
                {
                    firstOrderDate = firstOrder.CreatedTime;
                }
            }
        }
        public virtual DateTime? FirstOrderDate { get { return firstOrderDate; } }
    }
    
    [Flags]
    public enum CustomerSource
    {
        [Alias("未知")]
        Unknown,
        /// <summary>
        /// 点对点，从客户信息收集至最终签约完成由销售一人完成
        /// </summary>
        [Alias("直销")]
        P2P = 1,
        [Alias("呼叫中心")]
        CallCenter = 2,
        [Alias("网站")]
        WebSite = 4,
        [Alias("渠道")]
        Channel = 8,
        [Alias("直销渠道")]
        Introduction = 2 ^ 4,

    }
}
